import Vue from 'vue'
import Element from 'element-ui'
import locale from 'element-ui/lib/locale/lang/en'

import css from '@/assets/css.css'
import root from '@/assets/root.css'
// import iconfont from '@/utils/iconfont.js'
import Video from 'video.js'
import 'video.js/dist/video-js.css'
import 'element-ui/lib/theme-chalk/index.css';
import axios from "axios"
import url from "@/url/url.js";

// Vue.use(iconfont)
Vue.use(Element, { locale })

Vue.prototype.$bus = new Vue();
Vue.prototype.$http = axios;
Vue.prototype.$url = url;
Vue.prototype.$video = Video
Vue.config.productionTip = false


//JS Date格式化为yyyy-MM-dd类字符串
Date.prototype.format = function(format) {
  var o = {
    "M+": this.getMonth() + 1, //month
    "d+": this.getDate(), //day
    "h+": this.getHours(), //hour
    "m+": this.getMinutes(), //minute
    "s+": this.getSeconds(), //second
    "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
    "S": this.getMilliseconds() //millisecond
  }
  if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o)
    if (new RegExp("(" + k + ")").test(format))
      format = format.replace(RegExp.$1,
        RegExp.$1.length == 1 ? o[k] :
          ("00" + o[k]).substr(("" + o[k]).length));
  return format;
}

Vue.prototype.$formatDuring = function(mss) {

  var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

  var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));

  var seconds = ((mss % (1000 * 60)) / 1000).toFixed(0);

  var h = hours > 10 ? hours : '0' + hours;
  var m = minutes > 10 ? minutes : '0' + minutes;
  var s = seconds > 10 ? seconds : '0' + seconds;

  //return h + " : " + m + " : " + s;
  return m + " : " + s;

}
